home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / SRC1229A.ARJ / ENETDUMP.C < prev    next >
C/C++ Source or Header  |  1991-01-27  |  967b  |  54 lines

  1. /* Ethernet header tracing routines
  2.  * Copyright 1991 Phil Karn, KA9Q
  3.  */
  4. #include <stdio.h>
  5. #include "global.h"
  6. #include "mbuf.h"
  7. #include "enet.h"
  8. #include "trace.h"
  9.  
  10. void
  11. ether_dump(fp,bpp,check)
  12. FILE *fp;
  13. struct mbuf **bpp;
  14. int check;    /* Not used */
  15. {
  16.     struct ether ehdr;
  17.     char s[20],d[20];
  18.  
  19.     ntohether(&ehdr,bpp);
  20.     pether(s,ehdr.source);
  21.     pether(d,ehdr.dest);
  22.     fprintf(fp,"Ether: len %u %s->%s",ETHERLEN + len_p(*bpp),s,d);
  23.  
  24.     switch(ehdr.type){
  25.         case IP_TYPE:
  26.             fprintf(fp," type IP\n");
  27.             ip_dump(fp,bpp,1);
  28.             break;
  29.         case REVARP_TYPE:
  30.             fprintf(fp," type REVARP\n");
  31.             arp_dump(fp,bpp);
  32.             break;
  33.         case ARP_TYPE:
  34.             fprintf(fp," type ARP\n");
  35.             arp_dump(fp,bpp);
  36.             break;
  37.         default:
  38.             fprintf(fp," type 0x%x\n",ehdr.type);
  39.             break;
  40.     }
  41. }
  42. int
  43. ether_forus(iface,bp)
  44. struct iface *iface;
  45. struct mbuf *bp;
  46. {
  47.     /* Just look at the multicast bit */
  48.  
  49.     if(bp->data[0] & 1)
  50.         return 0;
  51.     else
  52.         return 1;
  53. }
  54.